
package getcurrency

import java.io._
import scala.io.Source

object GetCurrency {
  val from = "USD"
  val to = "JPY"
  val url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=" + from + to + "=X"
  
  /**
   * @param args the command line arguments
   */
  def main(args: Array[String]): Unit = {
    for (i <- 0 to 99) {
      val fw = new BufferedWriter(new FileWriter(if (i < 10) "quotes0" + i else "quotes" + i))

      for (i <- 0 until 100) {
        for (line <- Source.fromURL(url).getLines) {
          fw.write(line + "\n")
        }

        Thread.sleep(1000)
      }

      fw.close
    }
  }
}
